home *** CD-ROM | disk | FTP | other *** search
/ Aminet 50 / Aminet 50 (2002)(GTI - Schatztruhe)[!][Aug 2002].iso / Aminet / util / wb / BWS_Scalos.lha / BWS_Scalos / Scalos_Rename / Rename.prefs.e < prev    next >
Text File  |  2001-12-06  |  14KB  |  494 lines

  1. OPT PREPROCESS
  2. OPT STACK=32000
  3.  
  4. MODULE 'muimaster','libraries/mui','afc/rexxer','afc/localer',
  5. 'update',
  6. '*loc','*locnums','*other',
  7. 'amigaini','mui/betterstring_mcc','libraries/asl',
  8. 'amigainibase',
  9. 'amigalib/boopsi',
  10. 'tools/exceptions',
  11. 'utility/tagitem',
  12. 'utility/hooks',
  13. 'workbench/startup',
  14. 'tools/installhook'
  15.  
  16. DEF app=0,window,running=TRUE,comHook:hook,lo=0:PTR TO localer,loclang,
  17.     verN, verS, str[500]:STRING,up=0:PTR TO updObject,
  18.     deftitle, save,use,ref,quit,prefsfile[256]:STRING,
  19.     strpaths=0,listformat[100]:STRING,listtitle=1,listshow=1,highlight=1,
  20.     popS=1,showlabel=1,textmode=3,onret=0,myname,
  21.     prefBU=0:PTR TO LONG,updB,prfS,prfF,prfpf,
  22.     shtL=1,shnL=1,shpL=1,siT=1,snT=1,guide,ai=0:PTR TO amigaini,
  23.     spC,hiC,puC,onrC,lsC,ltC,shtC,shnC,shpC,slC,sliC,slnC
  24.  
  25. PROC main() HANDLE
  26.   DEF sigs=0, result,wb:PTR TO wbstartup, args:PTR TO wbarg
  27.  
  28. deftitle:='Scalos_Rename Prefs'
  29. verN:='40.9'
  30. verS:='$VER: Scalos_Rename Prefs 40.9 (06.12.2001)'
  31.  
  32. lo:=startlocale(lo)
  33. loclang:=lo.language()
  34.  
  35.  
  36.   IF (muimasterbase:=OpenLibrary(MUIMASTER_NAME,MUIMASTER_VMIN))=NIL THEN
  37.     Raise(failedOpen('muimaster.library'))
  38.  
  39.   IF (amigainibase:=OpenLibrary(AMIGAINI_NAME,AMIGAINI_VMIN))=NIL THEN
  40.     Raise(failedOpen('amigaini.library'))
  41.  
  42.   installhook(comHook,{comFunc})
  43.  
  44.   IF wbmessage=NIL
  45.   myname:=getprogname()
  46.   ELSE                        /* from wb */
  47.     wb:=wbmessage
  48.    args:=wb.arglist
  49.     NameFromLock(args[0].lock,str,256)
  50.     IF StrLen(args[0].name)>0 THEN AddPart(str, args[0].name,256)
  51.     myname:=news(str)
  52.   ENDIF
  53.  
  54. loadsettings()
  55.  
  56. guide:='Scalos:Docs/Scalos_Rename.guide'
  57. IF FileLength(guide)<1 THEN guide:='help:Scalos_Rename.guide' ELSE JUMP gotguide
  58. IF FileLength(guide)>1 THEN JUMP gotguide
  59. guide:=0
  60. gotguide:
  61.  
  62.  
  63.   app:=ApplicationObject,
  64.     MUIA_Application_Title      , deftitle,
  65.     MUIA_Application_Version    , verS,
  66.     MUIA_Application_Copyright  , '©2000/2002, Bruce Steers',
  67.     MUIA_Application_Author     , 'Bruce Steers',
  68.     MUIA_Application_Description, 'Rename Prefs Module for Scalos',
  69.     MUIA_Application_Base       , 'SCALOS_RENAME_PREFS',
  70.     MUIA_Application_HelpFile   , guide,
  71.  
  72.     SubWindow, window:= WindowObject,
  73.       MUIA_Window_Title    , 'Rename Prefs',
  74.       MUIA_Window_ScreenTitle    , deftitle,
  75.       MUIA_Window_ID       , "MAIN",
  76.       MUIA_Window_AppWindow, MUI_TRUE,
  77.       WindowContents, VGroup,
  78.  
  79.         Child, ScrollgroupObject,
  80.           MUIA_Scrollgroup_Contents, VirtgroupObject,
  81.           VirtualFrame,
  82.         Child, VGroup,
  83.         GroupFrame,
  84.         MUIA_FrameTitle,locs(lo,MSG_InfoLab),
  85.             Child, HGroup,
  86.          Child, RectangleObject, End,
  87.             Child, Label(locs(lo,MSG_ShowLab)),
  88.             Child, slC:=CheckMark(Abs(textmode>0)),
  89.          Child, RectangleObject, End,
  90.             End,
  91.           Child, VGroup,
  92.           GroupFrame,
  93.           MUIA_FrameTitle,locs(lo,MSG_LabItems),
  94.             Child, HGroup,
  95.             Child, RectangleObject, End,
  96.             Child, Label(locs(lo,MSG_ShowType)),
  97.             Child, sliC:=CheckMark(siT),
  98.             Child, RectangleObject, End,
  99.             End,
  100.             Child, HGroup,
  101.             Child, RectangleObject, End,
  102.             Child, Label(locs(lo,MSG_ShowName)),
  103.             Child, slnC:=CheckMark(snT),
  104.             Child, RectangleObject, End,
  105.             End,
  106.           End,
  107.         End,
  108.  
  109.         Child, ColGroup(4),
  110.         GroupFrame,
  111.         MUIA_FrameTitle,locs(lo,MSG_StringGad),
  112.         Child, RectangleObject, End,
  113.         Child, Label(locs(lo,MSG_StrPaths)),
  114.         Child, spC:=CheckMark(strpaths),
  115.         Child, RectangleObject, End,
  116.         ->End,
  117.  
  118.         ->Child, HGroup,
  119.         Child, RectangleObject, End,
  120.         Child, Label(locs(lo,MSG_ShowPop)),
  121.         Child, puC:=CheckMark(popS),
  122.         Child, RectangleObject, End,
  123.         ->End,
  124.  
  125.         ->Child, HGroup,
  126.         Child, RectangleObject, End,
  127.         Child, Label(locs(lo,MSG_Highlight)),
  128.         Child, hiC:=CheckMark(highlight),
  129.         Child, RectangleObject, End,
  130.         ->End,
  131.  
  132.         ->Child, HGroup,
  133.         Child, RectangleObject, End,
  134.         Child, Label(locs(lo,MSG_OnReturn)),
  135.         Child, onrC:=CheckMark(onret),
  136.         Child, RectangleObject, End,
  137.         ->End,
  138.  
  139.         End,
  140.  
  141.         Child, VGroup,
  142.         GroupFrame,
  143.         MUIA_FrameTitle,locs(lo,MSG_QueueList),
  144.  
  145.           Child, HGroup,
  146.           Child, RectangleObject, End,
  147.           Child, Label(locs(lo,MSG_ShowQueue)),
  148.           Child, lsC:=CheckMark(listshow),
  149.           Child, RectangleObject, End,
  150.           End,
  151.  
  152.           Child, HGroup,
  153.           Child, RectangleObject, End,
  154.           Child, Label(locs(lo,MSG_ShowTitles)),
  155.           Child, ltC:=CheckMark(listtitle),
  156.           Child, RectangleObject, End,
  157.           End,
  158.  
  159.           Child, VGroup,
  160.           GroupFrame,
  161.           MUIA_FrameTitle,locs(lo,MSG_ListColumns),
  162.             Child, HGroup,
  163.             Child, RectangleObject, End,
  164.             Child, Label(locs(lo,MSG_ShowType)),
  165.             Child, shtC:=CheckMark(shtL),
  166.             Child, RectangleObject, End,
  167.             End,
  168.             Child, HGroup,
  169.             Child, RectangleObject, End,
  170.             Child, Label(locs(lo,MSG_ShowName)),
  171.             Child, shnC:=CheckMark(shnL),
  172.             Child, RectangleObject, End,
  173.             End,
  174.             Child, HGroup,
  175.             Child, RectangleObject, End,
  176.             Child, Label(locs(lo,MSG_ShowPath)),
  177.             Child, shpC:=CheckMark(shpL),
  178.             Child, RectangleObject, End,
  179.             End,
  180.           End,
  181.  
  182.         End,
  183.  
  184.               Child, HGroup,
  185.               Child, Label2('MyName'),
  186.                 Child, PopaslObject,
  187.                   MUIA_Popstring_String, prfS := BetterStringObject,
  188.                   StringFrame,
  189.                   MUIA_String_Contents,prefsfile,
  190.                   MUIA_CycleChain,1,
  191.                   End,
  192.                 MUIA_Popstring_Button, prfpf := PopButton(MUII_PopFile),
  193.                 ASLFR_TITLETEXT, 'Select Prefs Editor...',
  194.                 End,
  195.               Child, prfF:=SimpleButton('Get'),
  196.               End,
  197.               End,
  198.               End,
  199.  
  200.  
  201.         Child, HGroup,
  202.         GroupFrame,
  203.         Child, save:=SimpleButton(locs(lo,GAD_Save)),
  204.         Child, use:=SimpleButton(locs(lo,GAD_Use)),
  205.         End,
  206.       Child, ref:=SimpleButton(locs(lo,GAD_Refresh)),
  207.       Child, updB:=SimpleButton(locs(lo,GAD_Update)),
  208.       Child, quit:=SimpleButton(locs(lo,GAD_Ignore)),
  209.  
  210.       End,
  211.     End,
  212.   End
  213.  
  214.   IF (app=NIL) THEN Raise(locs(lo,MSG_NoApp))
  215.  
  216.   doMethodA(app,[MUIM_MultiSet,MUIA_Weight,0,prfF,0])
  217.  
  218.   doMethodA(window,[MUIM_Notify,MUIA_Window_CloseRequest,MUI_TRUE,
  219.     app,2,MUIM_Application_ReturnID,MUIV_Application_ReturnID_Quit])
  220.  
  221.   doMethodA(quit,[MUIM_Notify,MUIA_Pressed,0,
  222.     app,2,MUIM_Application_ReturnID,"canc"])
  223.  
  224.   doMethodA(prfF,[MUIM_Notify,MUIA_Pressed,0,
  225.     prfS,3,MUIM_Set,MUIA_String_Contents,myname])
  226.  
  227.   doMethodA(ref,[MUIM_Notify,MUIA_Pressed,0,
  228.     app,2,MUIM_Application_ReturnID,"ref"])
  229.  
  230.   doMethodA(updB,[MUIM_Notify,MUIA_Pressed,0,
  231.     app,2,MUIM_Application_ReturnID,"upd"])
  232.  
  233.   doMethodA(save,[MUIM_Notify,MUIA_Pressed,0,
  234.     app,2,MUIM_Application_ReturnID,"save"])
  235.   doMethodA(use,[MUIM_Notify,MUIA_Pressed,0,
  236.     app,2,MUIM_Application_ReturnID,"use"])
  237.  
  238.     doMethodA(spC,[MUIM_Notify,MUIA_Selected,MUIV_EveryTime,
  239.        app,4,MUIM_CallHook,comHook,"sp",MUIV_TriggerValue])
  240.     doMethodA(hiC, [MUIM_Notify,MUIA_Selected,MUIV_EveryTime,
  241.        app,4,MUIM_CallHook,comHook,"hi",MUIV_TriggerValue])
  242.     doMethodA(puC, [MUIM_Notify,MUIA_Selected,MUIV_EveryTime,
  243.        app,4,MUIM_CallHook,comHook,"pop",MUIV_TriggerValue])
  244.     doMethodA(onrC, [MUIM_Notify,MUIA_Selected,MUIV_EveryTime,
  245.        app,3,MUIM_WriteLong,MUIV_TriggerValue,{onret}])
  246.  
  247.     doMethodA(slC, [MUIM_Notify,MUIA_Selected,MUIV_EveryTime,
  248.        app,4,MUIM_CallHook,comHook,"sl",MUIV_TriggerValue])
  249.  
  250.     doMethodA(sliC, [MUIM_Notify,MUIA_Selected,MUIV_EveryTime,
  251.        app,4,MUIM_CallHook,comHook,"slI",MUIV_TriggerValue])
  252.  
  253.     doMethodA(slnC, [MUIM_Notify,MUIA_Selected,MUIV_EveryTime,
  254.        app,4,MUIM_CallHook,comHook,"slN",MUIV_TriggerValue])
  255.  
  256.  
  257.  
  258.     doMethodA(lsC, [MUIM_Notify,MUIA_Selected,MUIV_EveryTime,
  259.        app,4,MUIM_CallHook,comHook,"shoL",MUIV_TriggerValue])
  260.     doMethodA(ltC, [MUIM_Notify,MUIA_Selected,MUIV_EveryTime,
  261.        app,3,MUIM_WriteLong,MUIV_TriggerValue,{listtitle}])
  262.  
  263. doMethodA(shtC, [MUIM_Notify,MUIA_Selected,MUIV_EveryTime,
  264.        app,4,MUIM_CallHook,comHook,"shT",MUIV_TriggerValue])
  265. doMethodA(shnC, [MUIM_Notify,MUIA_Selected,MUIV_EveryTime,
  266.        app,4,MUIM_CallHook,comHook,"shN",MUIV_TriggerValue])
  267. doMethodA(shpC, [MUIM_Notify,MUIA_Selected,MUIV_EveryTime,
  268.        app,4,MUIM_CallHook,comHook,"shP",MUIV_TriggerValue])
  269.  
  270.  
  271. set(puC,MUIA_Disabled,Abs(strpaths=0))
  272.  
  273.   doMethodA(app,[MUIM_MultiSet,MUIA_Disabled,Abs(showlabel=0),slnC,sliC,0])
  274.   doMethodA(app,[MUIM_MultiSet,MUIA_Disabled,Abs(listshow=0),shpC,shnC,shtC,ltC,0])
  275.  
  276.     up:=NEW [app,
  277.                 window,
  278.                 'Scalos_Rename',
  279.                 deftitle,
  280.                 verS,
  281.  
  282.                 locs(lo,MSG_chk),
  283.                 locs(lo,MSG_YesNo),
  284.                 locs(lo,MSG_Open),
  285.                 locs(lo,MSG_unfound),
  286.                 locs(lo,MSG_latest),
  287.                 locs(lo,MSG_better),
  288.                 locs(lo,MSG_found),
  289.                 locs(lo,MSG_NewVerGads),
  290.                 locs(lo,MSG_aborted),
  291.                 locs(lo,MSG_UpdError),
  292.                 locs(lo,MSG_complete)]:updObject
  293.  
  294.   set(window,MUIA_Window_Open,MUI_TRUE)
  295.  
  296.   WHILE running
  297.   result:=doMethodA(app,[MUIM_Application_NewInput,{sigs}])
  298.   SELECT result
  299.   CASE MUIV_Application_ReturnID_Quit; compareprefs() ;running:=0
  300.  
  301.   CASE "save";writeprefs(1,1); running:=0
  302.   CASE "use"; writeprefs(0,1); running:=0
  303.   CASE "ref"; writeprefs(0,1);
  304.   CASE "canc"; running:=0
  305.   CASE "upd"; update(up)
  306.   ENDSELECT
  307.  
  308.     IF (running AND sigs) THEN sigs:=Wait(sigs)
  309.  
  310.   ENDWHILE
  311.  
  312. IF result<>-5 THEN compareprefs()
  313.  
  314. EXCEPT DO
  315.  
  316. IF exception THEN muireq(deftitle,StringF(str,'\s !\n\s',locs(lo,MSG_EXCEPT),exception),'_OK',app,0)
  317.  
  318.   IF app THEN Mui_DisposeObject(app)
  319.   IF amigainibase THEN CloseLibrary(amigainibase)
  320.   IF muimasterbase THEN CloseLibrary(muimasterbase)
  321.  
  322.   IF up  THEN END up
  323.   IF lo THEN END lo
  324. ENDPROC
  325.  
  326.  
  327. PROC loadsettings()
  328.  
  329. NEW ai
  330. Ini_Init(ai,'ENV:Scalos/Rename.ini')
  331. Ini_Read(ai)
  332.  
  333. IF ai.error
  334. Ini_NewGroup(ai,'Misc Options')
  335. Ini_NewGroup(ai,'Text Options')
  336. Ini_NewGroup(ai,'String Options')
  337. Ini_NewGroup(ai,'List Options')
  338. ENDIF
  339.  
  340. Ini_FindGroup(ai,'[Misc Options]')
  341. StringF(prefsfile,'\s',Ini_GetStr(ai,'PREFSFILE','Scalos:Prefs/Modules/Rename.prefs'))
  342.  
  343. Ini_FindGroup(ai,'Text Options')
  344. showlabel:=Ini_GetInt(ai,'TEXTSHOW',1)
  345. textmode:=Ini_GetInt(ai,'TEXTMODE',3)
  346.  
  347. Ini_FindGroup(ai,'[String Options]')
  348. strpaths:=Ini_GetInt(ai,'STRINGPATHS',0)
  349. highlight:=Ini_GetInt(ai,'HIGHLIGHT',1)
  350. popS:=Ini_GetInt(ai,'POPFILE',1)
  351. onret:=Ini_GetInt(ai,'ONRETURN',0)
  352.  
  353. Ini_FindGroup(ai,'[List Options]')
  354. StringF(listformat,'\s',Ini_GetStr(ai,'LISTFORMAT','COL=0 BAR,COL=1 BAR,COL=2'))
  355. listtitle:=Ini_GetInt(ai,'LISTTITLE=',1)
  356. listshow:=Ini_GetInt(ai,'LISTSHOW',1)
  357.  
  358. processformatstr(listformat)
  359. gettextmode()
  360. backupprefs()
  361. ENDPROC
  362.  
  363. PROC backupprefs(); DEF c
  364. IF prefBU THEN DisposeLink(prefBU)
  365. prefBU:=List(ai.length)
  366. FOR c:=0 TO ai.length-1 DO ListAdd(prefBU,[news(ai.list[c])])
  367. ENDPROC
  368.  
  369. PROC buildformatstr(); DEF s[50]:STRING
  370. IF shtL THEN StrAdd(s,'COL=0')
  371. IF shnL THEN StrAdd(s,IF StrLen(s)>0 THEN ' BAR,COL=1' ELSE 'COL=1')
  372. IF shpL THEN StrAdd(s,IF StrLen(s)>0 THEN ' BAR,COL=2' ELSE 'COL=2')
  373. StringF(listformat,'\s',s)
  374. ENDPROC
  375.  
  376. PROC processformatstr(fs)
  377. shtL:=Abs(InStr(fs,'COL=0')<>-1)
  378. shnL:=Abs(InStr(fs,'COL=1')<>-1)
  379. shpL:=Abs(InStr(fs,'COL=2')<>-1)
  380. ENDPROC
  381.  
  382. PROC compareprefs(); DEF mode,changed=0
  383.  
  384. prefs2ini()
  385.  
  386. FOR mode:=0 TO Min(ListLen(prefBU),ListLen(ai.list))-1 DO IF StrCmp(prefBU[mode],ai.list[mode])=0 THEN changed:=1
  387.  
  388.  
  389. IF changed=0 THEN RETURN
  390.  
  391. mode:=muireq(deftitle,locs(lo,MSG_PrefChange),StringF(str,'\s|\s|\s',locs(lo,GAD_Save),locs(lo,GAD_Use),locs(lo,GAD_Ignore)),app,window)
  392. IF mode=0 THEN RETURN
  393. writeprefs(mode)
  394. ENDPROC
  395.  
  396. PROC writeprefs(arcmode,doini=0)
  397.  
  398. IF doini THEN prefs2ini()
  399.  
  400. Ini_Write(ai)
  401.     IF arcmode=1
  402.     ai.filename:='ENVARC:Scalos/Rename.ini'
  403.     Ini_Write(ai)
  404.     ai.filename:='ENV:Scalos/Rename.ini'
  405.     ENDIF
  406. backupprefs()
  407. updateopenguis()
  408. ENDPROC
  409.  
  410. PROC prefs2ini()
  411. Ini_FindGroup(ai,'[Text Options]')
  412. settextmode()
  413. Ini_SetInt(ai,'TEXTSHOW',showlabel)
  414. Ini_SetInt(ai,'TEXTMODE',textmode)
  415.  
  416. Ini_FindGroup(ai,'[String Options]')
  417. Ini_SetInt(ai,'STRINGPATHS',strpaths)
  418. Ini_SetInt(ai,'HIGHLIGHT',highlight)
  419. Ini_SetInt(ai,'POPFILE',popS)
  420. Ini_SetInt(ai,'ONRETURN',onret)
  421.  
  422. Ini_FindGroup(ai,'[List Options]')
  423. Ini_SetStr(ai,'LISTFORMAT',listformat)
  424. Ini_SetInt(ai,'LISTTITLE',listtitle)
  425. Ini_SetInt(ai,'LISTSHOW',listshow)
  426. ENDPROC
  427.  
  428. PROC failedOpen(name); DEF msg[256]:STRING; StringF(msg,'\s \s',locs(lo,MSG_Open),name); ENDPROC msg
  429.  
  430. PROC comFunc(d:PTR TO LONG); DEF a
  431. a:=d[]
  432. SELECT a
  433. CASE "pop"; popS:=d[1]
  434. CASE "sp"; strpaths:=d[1]; set(puC,MUIA_Disabled,Abs(strpaths=0))
  435. CASE "hi"; highlight:=d[1]
  436.  
  437. CASE "slI"; siT:=d[1]; settextmode(); reftextmode()
  438. CASE "slN"; snT:=d[1]; settextmode(); reftextmode()
  439.  
  440. CASE "sl"; showlabel:=d[1];
  441.   doMethodA(app,[MUIM_MultiSet,MUIA_Disabled,Abs(showlabel=0),slnC,sliC,0])
  442.   IF (showlabel) AND (snT=0) AND (siT=0) THEN
  443.   doMethodA(app,[MUIM_MultiSet,MUIA_Selected,1,slnC,sliC,0])
  444.  
  445. CASE "shoL"; listshow:=d[1];
  446.   doMethodA(app,[MUIM_MultiSet,MUIA_Disabled,Abs(listshow=0),shpC,shnC,shtC,ltC,0])
  447.   IF (listshow) AND (shtL=0) AND (shnL=0) AND (shpL=0) THEN
  448.   doMethodA(app,[MUIM_MultiSet,MUIA_Selected,1,shtC,shnC,shpC,0])
  449. CASE "shT"; shtL:=d[1]; buildformatstr(); refformatstr()
  450. CASE "shN"; shnL:=d[1]; buildformatstr(); refformatstr()
  451. CASE "shP"; shpL:=d[1]; buildformatstr(); refformatstr()
  452. ENDSELECT
  453. ENDPROC
  454.  
  455. PROC settextmode()
  456. textmode:=0
  457. IF siT THEN textmode:=1
  458. IF snT THEN textmode:=textmode+2
  459. ENDPROC
  460.  
  461. PROC gettextmode()
  462. siT:=Abs(Odd(textmode))
  463. snT:=Abs(textmode>=2)
  464. ENDPROC
  465.  
  466. PROC reftextmode()
  467.   set(slC,MUIA_Selected,Abs(textmode>0))
  468. ENDPROC
  469.  
  470. PROC refformatstr()
  471.   set(lsC,MUIA_Selected,Abs(StrLen(listformat)>0))
  472. ENDPROC
  473.  
  474. PROC updateopenguis(); DEF c,rx=NIL:PTR TO rexxer
  475. NEW rx.rexxer('RENAME_SENDER')
  476.  FOR c:=1 TO 10
  477.  StringF(str,'SCALOS_RENAME.\d',c)
  478.   IF FindPort(str)
  479.   rx.send(str, 'SETPREFS')
  480.   ENDIF
  481.  ENDFOR
  482. END rx
  483. ENDPROC
  484.  
  485. PROC getprogname(); DEF l,d,f[56]:STRING
  486. IF l:=GetProgramDir()
  487. d:=String(256)
  488. NameFromLock(l,d,256)
  489. GetProgramName(f,56)
  490. AddPart(d,f,256)
  491. SetStr(d,StrLen(d))
  492. ENDIF
  493. ENDPROC d
  494.